//这里是正则测试
var str = "\
    aaa\n\
    \n\
    jsfzhejd\n\
    ajdflajd\n\
    ";

console.log(str);
console.log('-----------------------------------------------');

var str2 = str.replace(/^/gm, '<p>');  //行首的添加<p>标签

console.log(str2);
console.log('-----------------------------------------------');

var str3 = str.replace(/^/gm, '<p>')    //行首的添加<p>标签
              .replace(/$/gm, '</p>');  //行尾的添加</p>标签
console.log(str3);